package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 解决方案类型枚举
 * 
 * @author S-01 Module Designer
 * @version 2.0
 * @since 2025-11-10
 */
public enum SolutionType implements BaseEnum {
    RESCHEDULE("reschedule", "重新安排"),
    CHANGE_VENUE("change_venue", "更换考场"),
    ADD_INVIGILATOR("add_invigilator", "增加监考员"),
    SPLIT_EXAM("split_exam", "拆分考试"),
    MERGE_EXAM("merge_exam", "合并考试"),
    CANCEL_EXAM("cancel_exam", "取消考试"),
    MANUAL_RESOLVE("manual_resolve", "手动解决"),
    AUTO_RESOLVE("auto_resolve", "自动解决"),
    IGNORE("ignore", "忽略冲突"),
    POSTPONE("postpone", "延期处理"),
    ESCALATE("escalate", "上报处理"),
    TEMPORARY("temporary", "临时解决方案"),
    PERMANENT("permanent", "永久解决方案"),
    ALTERNATIVE("alternative", "替代方案"),
    COMPROMISE("compromise", "折中方案"),
    PRIORITY("priority", "优先处理"),
    STANDARD("standard", "标准方案"),
    CUSTOM("custom", "自定义方案"),
    SYSTEM("system", "系统方案"),
    EXTERNAL("external", "外部方案"),
    INTERNAL("internal", "内部方案"),
    TECHNICAL("technical", "技术方案"),
    ADMINISTRATIVE("administrative", "行政方案"),
    EMERGENCY("emergency", "紧急方案"),
    ROUTINE("routine", "常规方案");

    private final String code;
    private final String description;

    SolutionType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 根据代码查找枚举值
     *
     * @param code 枚举代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码不存在
     */
    public static SolutionType fromCode(String code) {
        for (SolutionType type : SolutionType.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown solution type code: " + code);
    }

    /**
     * 根据描述查找枚举值
     *
     * @param description 枚举描述
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果描述不存在
     */
    public static SolutionType fromDescription(String description) {
        for (SolutionType type : SolutionType.values()) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown solution type description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}